import { sendMail,sendHotWater } from "./main"
import axios from 'axios'
import { dateFormat } from '../utils/functions'
export const CORN_MAIN1 = (city,username,to) =>{
  const params = {
    appid:12185594,
    appsecret:'aLP3gTp9',
    unescape:1,
    city
  }
  const time = dateFormat('YYYY-MM-DD hh:mm:ss',new Date())
  axios
  .get('https://yiketianqi.com/free/day',{params})
  .then(({data})=>{
    const conf = {
      to,
      title:`${username}您好`,
      text:'...',
      templateconf:{
        username,
        time,
        code:'10086',
        data
      }
    }
    try{
      sendMail(conf)
      console.log(`${time}-${username}`)
    }catch(e){
      console.log("发送异常",time)
    }
  })
}
export const CORN_MAIN2 = (fromname,username,to) => {
  const time = dateFormat('YYYY-MM-DD hh:mm:ss',new Date())
  const conf = {
    to,
    title:`${username}您好`,
    templateconf:{
      fromname,
      username,
      time,
    }
  }
  try{
    sendHotWater(conf)
    console.log(`${time}-${username}`)
  }catch(e){
    console.log(e)
    console.log("发送异常",time)
  }
}
